//https://leetcode.cn/problems/climbing-stairs/
package codeRandomThoughts.Test70爬楼梯;

/**
 * 动态规划
 */
public class Solution2 {
    public int climbStairs(int n) {
        //爬到第i阶有dp[i]种方法
        int[] dp = new int[n + 1];

        //初始化
        dp[1] = 1;
        dp[2] = 2;
        for (int i = 3; i < dp.length; i++) {
            dp[i] = dp[i - 1] + dp[i - 2];
        }
        return dp[n];
    }
}
